<?php
class Territory extends AppModel {
    var $name = 'Territory';
    var $primaryKey = 'territory_id';
    var $displayField = 'territory_name';

    var $belongsTo = array(
        'ParentTerritory' => array(
            'className' => 'Territory',
            'foreignKey' => 'parent_territory_id'
        ),
        'TerritoryType' => array(
            'className' => 'LookupValue',
            'foreignKey' => 'lookup_value_id',
            'conditions' => array('TerritoryType.lookup_type' => 'TERRITORY_TYPE'),
            'order' => 'TerritoryType.meaning'
        )
    );

    var $hasMany = array(
        'DependentTerritory' => array(
                'className' => 'Territory',
                'foreignKey' => 'parent_territory_id',
                'dependent' => false
        ),
        'ProvinceAddress' => array(
                'className' => 'Address',
                'foreignKey' => 'province_id',
                'dependent' => false
        ),
        'CityAdderss' => array(
                'className' => 'Address',
                'foreignKey' => 'city_id',
                'dependent' => false
        ),
        'NeighboorhoodAddress' => array(
                'className' => 'Address',
                'foreignKey' => 'neighborhood_id',
                'dependent' => false
        )
    );
}
?>
